//	游戏房间信息类（记录游戏房间内的基本信息，子类由该类进行扩展）

package anshe.struct.game
{
	import anshe.inface.IStruct;
	import anshe.struct.ExUserNames;

	public class GRoomInfo extends Object implements IStruct
	{
		public var master:String;		//	房主名称
		public var soName:String;		//	房间 SharedObject 名称
		public var roomID:Number;		//	房间 ID 号
		public var maxPlayer:Number;	//	玩家上限
		public var nowPlayer:Number;	//	当前已经入坐的玩家
		public var isPlaying:Boolean;	//	游戏是否已经开始 
		
		private var masterName:ExUserNames;	//	用户名称

		public function GRoomInfo()
		{
			master = "";
			soName = "";
			roomID = 0;
			maxPlayer = 0;
			nowPlayer = 0;
			isPlaying = false;
		}
		
		public function get masterNick():String
		{
			masterName = new ExUserNames(master);
			
			return masterName.dispName;
		}
		
		public final function fromObject(obj:Object):IStruct
		{
			this.roomID = obj.gameRoomId;
			this.soName = obj.gameRoomSoName;
			this.maxPlayer = obj.maxPlayer;
			this.nowPlayer = obj.nowPlayer;
			this.isPlaying = obj.isPlaying;
			this.master = obj.createrName;
			
			UpdataFromObject(obj);
			
			return this;
		}
		
		public final function toObject():Object
		{
			var obj:Object = new Object();
			obj.roomID = this.roomID;
			obj.soName = this.soName;
			obj.maxPlayer = this.maxPlayer;
			obj.nowPlayer = this.nowPlayer;
			obj.isPlaying = this.isPlaying;
			obj.master = this.master;
			
			UpdataToObject(obj);
			
			return obj;
		}
		
		public function toString():String
		{
			return 	" roomID: " + this.roomID +
					" soName: " + this.soName +
					" maxPlayer: " + this.maxPlayer +
					" nowPlayer: " + this.nowPlayer +
					" isPlaying: " + this.isPlaying +
					" master: " + this.master;
		}
		
		//---------------------------------------------------
		
		//	由子类进行补充,将需要赋值的变量继续赋值
		protected function UpdataFromObject(obj:Object):void
		{			
		}
		
		//	由子类进行补充,将需要转换成为 Object 的对象直接进行转换
		protected function UpdataToObject(obj:Object):void
		{			
		}
	}
}